//   Google Maps User Control for ASP.Net version 1.0:
//   ========================
//   Copyright (C) 2008  Shabdar Ghata 
//   Email : ghata2002@gmail.com
//   URL : http://www.shabdar.org

//   This program is free software: you can redistribute it and/or modify
//   it under the terms of the GNU General Public License as published by
//   the Free Software Foundation, either version 3 of the License, or
//   (at your option) any later version.

//   This program is distributed in the hope that it will be useful,
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   GNU General Public License for more details.

//   You should have received a copy of the GNU General Public License
//   along with this program.  If not, see <http://www.gnu.org/licenses/>.

//   This program comes with ABSOLUTELY NO WARRANTY.
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.Drawing;
using System.Web.Services;

public partial class GoogleMapForASPNet : System.Web.UI.UserControl
{
    #region Properties

    GoogleObject _googlemapobject = new GoogleObject();
    double longs;
    double lats;
    int zoom;
    string width;
    string height;

    public int Zoom
    {
        get { return zoom; }
        set { zoom = value; }
    }
    public string Width
    {
        get { return width; }
        set { width = value; }
    }
    public string  Height
    {
        get { return height; }
        set { height = value; }
    }
    public GoogleObject GoogleMapObject
    {
        get { return _googlemapobject; }
        set { _googlemapobject = value; }
    }
    public double Longs
    {
        get { return longs; }
        set { longs = value; }
    }
    public double Lats
    {
        get { return lats; }
        set { lats = value; }
    }

    #endregion


    protected void Page_Load(object sender, EventArgs e)
    {
        
        if (!IsPostBack)
        {
            Session["GOOGLE_MAP_OBJECT"] = GoogleMapObject;
            _googlemapobject.APIKey = ConfigurationManager.AppSettings["GoogleAPIKey"];
            _googlemapobject.Width = width; // You can also specify percentage(e.g. 80%) here
            _googlemapobject.Height = height;
            _googlemapobject.ZoomLevel = zoom;

            //Specify Center Point for map. Map will be centered on this point.
            _googlemapobject.CenterPoint = new GooglePoint("1",lats, longs );

        }
        else
        {
            GoogleMapObject = (GoogleObject)Session["GOOGLE_MAP_OBJECT"];
            GoogleMapObject.ZoomLevel = 12;
            if (TextBox1.Text!="")
            {
                string[] bb = Text1.Text.Split(',');
                
                GooglePoint GP1 = new GooglePoint();
                double la = double.Parse(bb[0]);
                double lo = double.Parse(bb[1]);
                GP1.ID = TextBox1.Text;
                GP1.Latitude = la;
                GP1.Longitude = lo;
                //Specify bubble text here. You can use standard HTML tags here.
                GP1.InfoHTML = TextBox1.Text;
                //Specify icon image. This should be relative to root folder.
                GP1.IconImage = "icons/pushpin-blue.png";
                GoogleMapObject.Points.Add(GP1);


                _googlemapobject.CenterPoint = new GooglePoint("here", la + 0.05, lo - 0.05);

                TextBox1.Text = "";
            }
       
        }
    }
    //protected void bads_Click(object sender, EventArgs e)
    //{
         

    //    string[] bb = Text1.Text.Split(',');

    //    GooglePoint GP1 = new GooglePoint();
    //    GP1.ID = TextBox1.Text;
    //    GP1.Latitude = double.Parse(bb[0]);
    //    GP1.Longitude = double.Parse(bb[1]);
    //    //Specify bubble text here. You can use standard HTML tags here.
    //    GP1.InfoHTML = TextBox1.Text;
    //    //Specify icon image. This should be relative to root folder.
    //    GP1.IconImage = "icons/pushpin-blue.png";
    //    _googlemapobject.Points.Add(GP1);

    //    TextBox1.Text = "";

    //}
    public void setseen()
    {

        Page.ClientScript.RegisterStartupScript(this.GetType(), "reports", "showMap();", true);


    }
}
